import { PageModalService } from 'src/app/shared/service/page-modal-service';
// tslint:disable
import { Component, Input, OnInit, ViewChild, ElementRef } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { Platform } from '@ionic/angular';
import { isArray } from 'util';
import { ChooseCityComponent } from 'src/app/coms/choose-city/choose-city.component';
import { AppGlobalService } from '../../shared/service/app-global.service';
import { HttpService } from '../../shared/service/http.service';
import { MapBaiduService } from 'src/app/shared/service/map.baiduapi';
declare var cordova: any;
declare var BMap;
declare var BMAP_ANCHOR_TOP_RIGHT;
declare var BMAP_ANCHOR_TOP_LEFT;
@Component({ selector: 'app-data-map', templateUrl: './data-map.component.html', styleUrls: ['./data-map.component.scss'] })
export class DataMapComponent implements OnInit {
    @ViewChild('searchBar') searchBar; @ViewChild('container') mapElement: ElementRef; @ViewChild('numberCtrl') numberCtrlElement: ElementRef; @ViewChild('countCtrl') countCtrlElement: ElementRef; @ViewChild('chartLabel') chartCenterLabel: ElementRef;
    constructor(private appGlobalService: AppGlobalService, 
        private pageModalService: PageModalService, private httpService: HttpService, public modalController: ModalController, private platform: Platform,private mapBaiduService : MapBaiduService) { }
    @Input() tagData: any; provinceIcon = new BMap.Icon("/assets/img/map_icon_sign@3x.png", new BMap.Size(25, 28)); cityOp = new BMap.Icon("/assets/img/map/city_op.png", new BMap.Size(50, 29)); districtOp = new BMap.Icon("/assets/img/map/region_op.png", new BMap.Size(95, 29)); locationIcon = new BMap.Icon("/assets/img/map/map_icon_location@3x.png", new BMap.Size(26, 26)); localPoint = { lng: 116.402544, lat: 39.908958 }; map: any; keyword: any; industryBean: { value: 0, checkLabel: string }; areaBean: { value: 0, checkLabel: '全部' }; contextFormId = 0; stateDataArray = []; industryDataArray = []; industryDataPageSize = 4; industryCurrPageNum = 0; dataType = 1; transferRentState = 0; dataLevel = 'city'; dataLevelCode = 0; dataLevelLabel = ''; cityLabel = { name: '', code: 0, longitude: 0.0, latitude: 0.0 }; currentClickPt = { longitude: 0.0, latitude: 0.0 }; formatCountryData = { infoList: [], statistics: [], stateTabs: {} }; formatProvinceData = { infoList: [], statistics: [], stateTabs: {} }; formatCityData = { infoList: [], statistics: [], stateTabs: {} }; formatDistrictData = { infoList: [], statistics: [], stateTabs: {} }; formatPointData = { infoList: [], statistics: [], stateTabs: {} }; checkIndustry = 0; shopMark; shopMarkIcon; subTabsState = 1; streetDetail; chooseCityName; appTypeCustom: any;
    ngOnInit() {
        this.industryBean = { value: 0, checkLabel: '全部' };
        this.areaBean = { value: 0, checkLabel: '全部' }; this.keyword = '';
        const bodyStyles = window.getComputedStyle(document.body);
        this.appTypeCustom = bodyStyles.getPropertyValue('--appTypeCustom').trim().replace('"', '').replace('"', '');
    }
    ngAfterViewInit() {
        const that = this; setTimeout(() => {
            that.initMap(that.localPoint);
            const h = window.innerHeight;
            console.log('window.innerHeight =' + window.innerHeight);
            console.log('document.documentElement.clientHeight =' + document.documentElement.clientHeight);
            console.log('document.body.clientHeight =' + document.body.clientHeight);
            if (document.getElementById('sNumberCount')) { document.getElementById('sNumberCount').setAttribute('style', 'top:' + (h - 265) + 'px !important'); }
            if (document.getElementById('subTabsCtrl') && document.getElementById('subTabsCtrl').style.display === 'block') { document.getElementById('subTabsCtrl').setAttribute('style', 'top:' + (h - 185) + 'px !important'); }
            if (document.getElementById('shopDetailCtrl')) { document.getElementById('shopDetailCtrl').setAttribute('style', 'top:' + (h - 185) + 'px !important;display:none;'); }
        }, 50);
    }
    initMap(pt, listData?) {
        const that = this;
        const map = this.map = new BMap.Map(this.mapElement.nativeElement, { minZoom: 5, maxZoom: 21, enableMapClick: true });
        map.setMapStyle({ style: 'googlelite' });
        let formatAppData = {
            tabs: { data: [{ id: 0, label: '', indexTab: 1 }, { id: 1, label: '', indexTab: 2 }], currentTab: 1 },
            infoList: [], code: '', level: 'province',
            shoplist: { label: '', link: { target: {} }, params: {} },
            sitinglist: { label: '', link: { target: {} }, params: {} }, statistics: [], location: { label: '' }, filter: { label: '' },
            stateTabs: {}
        };
        let formatInfoList = [];
        let formatId = 0;
        let dataTransferType = 1;
        if (that.tagData !== undefined) {
            that.refreshIndustryStateData();
            formatId = that.tagData.appDataMapList.id;
            formatAppData = listData ? listData : that.tagData.appDataMapList.data;
            formatInfoList = that.tagData.appDataMapList.data.infoList;
            that.contextFormId = formatId;
            dataTransferType = (that.tagData.appDataMapList.data.dataType !== undefined) ? parseInt(that.tagData.appDataMapList.data.dataType) : 1;
            that.dataType = dataTransferType;
            const pState = document.getElementById('subTabsCtrl-div1-p1'); const pIndustry = document.getElementById('subTabsCtrl-div1-p2'); const stateDiv = document.getElementById('subTabs-infoD1'); const industryDiv = document.getElementById('subTabs-infoD2'); const pagenation = document.getElementById('subTabsCtrl-div3');
            if (pState) { pState.innerHTML = that.dataType === 2 ? "业态" : that.tagData.appDataMapList.data.stateTabs.data[0].label; }
            if (pIndustry) { pIndustry.innerHTML = that.dataType === 2 ? "" : that.tagData.appDataMapList.data.stateTabs.data[1].label; }
            if (industryDiv) { industryDiv.style.display = (that.dataType === 2 || that.subTabsState === 2) ? "block" : "none"; }
            if (pagenation) { pagenation.style.display = (that.dataType === 2 || that.subTabsState === 2) ? "flex" : "none"; }
            if (stateDiv) { stateDiv.style.display = (that.dataType === 2 || that.subTabsState === 2) ? "none" : "block"; }
            if (pState && pIndustry) {
                if (that.dataType === 2 && pState.style.fontWeight === "normal") {
                    pState.style.fontWeight = "bold";
                    pState.style.color = "rgba(39,40,46,1)";
                    pIndustry.style.fontWeight = "normal";
                    pIndustry.style.color = "rgba(133,136,148,1)";
                } else if (that.dataType === 1) {
                    pState.style.fontWeight = that.subTabsState === 2 ? "normal" : "bold";
                    pState.style.color = that.subTabsState === 2 ? "rgba(133,136,148,1)" : "rgba(39,40,46,1)";
                    pIndustry.style.fontWeight = that.subTabsState === 2 ? "bold" : "normal";
                    pIndustry.style.color = that.subTabsState === 2 ? "rgba(39,40,46,1)" : "rgba(133,136,148,1)";
                }
            }
        }
        map.disableKeyboard();
        map.disableDoubleClickZoom();
        map.enableScrollWheelZoom();
        map.disableContinuousZoom();
        map.enablePinchToZoom();
        map.clearOverlays();
        if (that.numberCtrlElement !== undefined) { that.numberCtrlElement.nativeElement.style.display = "block"; }
        if (that.countCtrlElement !== undefined) { that.countCtrlElement.nativeElement.style.display = "none"; }
        function showLocationControl() { this.defaultAnchor = BMAP_ANCHOR_TOP_RIGHT; this.defaultOffset = new BMap.Size(10, 59); }
        showLocationControl.prototype = new BMap.Control();
        showLocationControl.prototype.initialize = () => {
            const div = document.createElement("div");
            div.style.width = "2.25rem";
            div.style.minWidth = "2.25rem";
            div.style.height = "2.25rem";
            if (this.appTypeCustom === 'LJ') { div.style.boxShadow = "0rem 0.06rem 0.25rem 0rem rgba(37,38,41,0.1)"; } else { div.style.boxShadow = "0rem 0.06rem 0.25rem 0rem rgba(39,40,46,0.1)"; }
            div.style.background = "rgba(255,255,255,1)";
            div.style.borderRadius = "0.31rem";
            div.onclick = (e) => {
                that.platform.ready().then(() => {
                    if (this.platform.is('cordova')) {
                        cordova.plugins.baidumap_location.getCurrentPosition((res) => {
                            // 国际转换坐标百度坐标
                            res = that.mapBaiduService.storageNewLocation(res);

                            const points = { lng: res.longitude, lat: res.latitude };
                            that.localPoint.lng = points.lng;
                            that.localPoint.lat = points.lat;
                            that.chartCenterLabel.nativeElement.innerHTML = res.district;
                            map.enablePinchToZoom();
                            map.centerAndZoom(new BMap.Point(that.localPoint.lng, that.localPoint.lat), 18);
                        }, (err) => {
                            if (err === 'show setting') {
                                console.log('show setting');
                                that.pageModalService.showSettingLocation();
                            } else {
                                that.appGlobalService.showToast("请在设置中允许铺铺旺APP使用您的位置信息", 1000, "middle");
                            }
                            return;
                        });
                    } else {
                        if (localStorage.getItem('locationFromWx')) {
                            const wxLocation = JSON.parse(localStorage.getItem('locationFromWx'));
                            const mapLocation = JSON.parse(localStorage.getItem('mapPosition'));
                            that.localPoint.lng = wxLocation.center.lng;
                            that.localPoint.lat = wxLocation.center.lat;
                            that.chartCenterLabel.nativeElement.innerHTML = mapLocation.name;
                            map.enablePinchToZoom();
                            map.centerAndZoom(new BMap.Point(mapLocation.center.lng, mapLocation.center.lat), 18);
                        } else {
                            const myCity = new BMap.LocalCity();
                            myCity.get((result) => {
                                if (result !== undefined) {
                                    that.localPoint.lng = result.center.lng;
                                    that.localPoint.lat = result.center.lat;
                                    that.chartCenterLabel.nativeElement.innerHTML = result.name;
                                    map.enablePinchToZoom();
                                    map.centerAndZoom(new BMap.Point(result.center.lng, result.center.lat), 18);
                                }
                            });
                        }
                    }
                });
            };
            const lcbtn = document.createElement("img");
            lcbtn.style.width = "1.13rem";
            lcbtn.style.height = "1.13rem";
            lcbtn.src = "assets/img/map/map_icon_location2@3x.png";
            lcbtn.style.marginTop = "0.19rem";
            lcbtn.style.marginLeft = "0.56rem";
            lcbtn.style.marginRight = "0.56rem";
            lcbtn.style.marginBottom = "0.19rem";
            const p = document.createElement("p");
            p.style.fontSize = "0.5rem";
            if (this.appTypeCustom === 'LJ') {
                p.style.color = "#575A61";
            } else {
                p.style.color = "rgba(92,94,102,1)";
            }
            p.style.fontWeight = "normal";
            p.style.textAlign = "center";
            p.appendChild(document.createTextNode(formatAppData.location.label));
            div.appendChild(lcbtn);
            div.appendChild(p);
            map.getContainer().appendChild(div);
            return div;
        };
        function showListControl() { this.defaultAnchor = BMAP_ANCHOR_TOP_RIGHT; this.defaultOffset = new BMap.Size(10, 10); }
        showListControl.prototype = new BMap.Control();
        showListControl.prototype.initialize = () => {
            const div = document.createElement("div");
            div.style.width = "2.25rem";
            div.style.minWidth = "2.25rem";
            div.style.height = "2.25rem";
            if (this.appTypeCustom === 'LJ') {
                div.style.boxShadow = "0rem 0.06rem 0.25rem 0rem rgba(37,38,41,0.1)";
            } else {
                div.style.boxShadow = "0rem 0.06rem 0.25rem 0rem rgba(39,40,46,0.1)";
            }
            div.style.background = "rgba(255,255,255,1)"; div.style.borderRadius = "0.31rem";
            div.onclick = (e) => {
                const transferTarget = {
                    pageId: formatAppData.shoplist.link.target, params: {
                        showName: this.transferRentState === 0 ? "#opportunity_transfer" : "#opportunity_rent",
                        filter: this.transferRentState === 0 ? {
                            opportunity_industry_id: this.industryBean.value,
                            opportunity_area: this.areaBean.value,
                            keyword: this.keyword,
                            opportunity_city_id: this.dataLevelCode.toString().substring(0, 4),
                            opportunity_district_id: this.dataLevelCode
                        } : {
                            opportunity_suit_industry: this.industryBean.value,
                            opportunity_area: this.areaBean.value,
                            keyword: this.keyword,
                            opportunity_city_id: this.dataLevelCode.toString().substring(0, 4),
                            opportunity_district_id: this.dataLevelCode
                        }
                        , pageNo: 1, dataType: dataTransferType
                    }, sessionId: localStorage.getItem('sessionId')
                };
                const sitingTarget = { pageId: formatAppData.sitinglist.link.target, params: { showName: "#opportunity_siting", filter: { opportunity_industry_id: this.industryBean.value, opportunity_area: this.areaBean.value, keyword: this.keyword, opportunity_expect_district: this.dataLevelCode }, pageNo: 1, dataType: dataTransferType }, sessionId: localStorage.getItem('sessionId') };
                sessionStorage.setItem("showName", dataTransferType === 1 ? "#opportunity_transfer" : "#opportunity_siting");
                this.appGlobalService.goToForward(dataTransferType === 1 ? transferTarget : sitingTarget);
            };
            const listBtn = document.createElement("img");
            listBtn.style.width = "1rem";
            listBtn.style.height = "1rem";
            listBtn.src = "assets/img/map/map_icon_list@3x.png";
            listBtn.style.marginTop = "0.31rem";
            listBtn.style.marginLeft = "0.5rem";
            listBtn.style.marginRight = "0.5rem";
            listBtn.style.marginBottom = "0.13rem";
            const p = document.createElement("p");
            p.style.fontSize = "0.5rem";
            if (this.appTypeCustom === 'LJ') {
                p.style.color = "#575A61";
            } else {
                p.style.color = "rgba(92,94,102,1)";
            }
            p.style.fontWeight = "normal";
            p.style.textAlign = "center";
            p.appendChild(document.createTextNode(this.dataType === 1 ? formatAppData.shoplist.label : formatAppData.sitinglist.label));
            div.appendChild(listBtn);
            div.appendChild(p);
            map.getContainer().appendChild(div);
            return div;
        };
        function showTabTransferSitingControl() { this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT; this.defaultOffset = new BMap.Size(10, 10); }
        showTabTransferSitingControl.prototype = new BMap.Control();
        showTabTransferSitingControl.prototype.initialize = () => {
            const div = document.createElement("div");
            const tab1 = document.createElement("button");
            tab1.style.width = "2.81rem";
            tab1.style.height = "2rem";
            tab1.style.borderRadius = "0.19rem";
            tab1.style.background = "rgba(255,255,255,1)";
            if (formatAppData.tabs.currentTab === undefined) { formatAppData.tabs.currentTab = 1; }
            if (parseInt(formatAppData.tabs.currentTab + '') === formatAppData.tabs.data[0].indexTab) {
                if (this.appTypeCustom === 'LJ') {
                    tab1.style.border = "0.03rem solid #FFAA00";
                    tab1.style.background = 'rgba(255, 202, 58, 0.1)';
                } else {
                    tab1.style.border = "0.03rem solid rgba(255,99,20,1)";
                    tab1.style.background = '#ffffff';
                }
            } else {
                tab1.style.border = "0rem";
            }
            tab1.style.textAlign = "center";
            tab1.style.marginTop = "0.13rem";
            tab1.style.marginLeft = "0.13rem";
            tab1.style.marginRight = "0.13";
            const pShop = document.createElement("p");
            pShop.style.width = "1.7rem";
            pShop.style.height = "0.81rem";
            pShop.style.fontSize = "0.81rem";
            if (parseInt(formatAppData.tabs.currentTab + '') === formatAppData.tabs.data[0].indexTab) {
                if (this.appTypeCustom === 'LJ') {
                    pShop.style.color = "#946C00";
                } else {
                    pShop.style.color = "rgba(255,99,20,1)";
                }
            } else {
                if (this.appTypeCustom === 'LJ') {
                    pShop.style.color = "#575A61";
                } else {
                    pShop.style.color = "rgba(92,94,102,1)";
                }
            }
            pShop.style.marginLeft = "0.63rem";
            pShop.appendChild(document.createTextNode(formatAppData.tabs.data[0].label));
            const tab2 = document.createElement("button");
            tab2.style.width = "2.81rem";
            tab2.style.height = "2rem";
            if (parseInt(formatAppData.tabs.currentTab + '') === formatAppData.tabs.data[0].indexTab) {
                tab2.style.border = "0px";
                tab2.style.background = '#ffffff';
            } else {
                if (this.appTypeCustom === 'LJ') {
                    tab2.style.border = "0.03rem solid #FFAA00";
                    tab2.style.background = 'rgba(255, 202, 58, 0.1)';
                } else {
                    tab2.style.border = "0.03rem solid rgba(255,99,20,1)";
                    tab2.style.background = '#ffffff';
                }
            }
            tab2.style.borderRadius = "0.19rem";
            tab2.style.textAlign = "center";
            tab2.style.marginTop = "0.13rem";
            const pSiting = document.createElement("p");
            pSiting.style.width = "1.7rem";
            pSiting.style.height = "0.81rem";
            pSiting.style.fontSize = "0.81rem";
            if (parseInt(formatAppData.tabs.currentTab + '') === formatAppData.tabs.data[0].indexTab) {
                if (this.appTypeCustom === 'LJ') {
                    pSiting.style.color = "#575A61";
                } else {
                    pSiting.style.color = "rgba(255,99,20,1)";
                }
            } else {
                if (this.appTypeCustom === 'LJ') {
                    pSiting.style.color = "#946C00";
                } else {
                    pSiting.style.color = "rgba(92,94,102,1)";
                }

            }
            pSiting.style.marginLeft = "0.63rem";
            pSiting.appendChild(document.createTextNode(formatAppData.tabs.data[1].label));
            tab1.appendChild(pShop);
            tab2.appendChild(pSiting);
            tab1.onclick = ((e) => {
                tab1.style.border = "0.03rem solid rgba(255,99,20,1)";
                tab2.style.border = "0rem";
                if (this.appTypeCustom === 'LJ') {
                    pShop.style.color = "#946C00";
                    pSiting.style.color = "#575A61";
                    tab1.style.background = 'rgba(255, 202, 58, 0.1)';
                    tab2.style.background = '#ffffff';
                } else {
                    pShop.style.color = "rgba(255,99,20,1)";
                    pSiting.style.color = "rgba(92,94,102,1)";
                    tab1.style.background = '#ffffff';
                    tab2.style.background = '#ffffff';
                }
                const params = {
                    content: {
                        level: "city",
                        code: this.cityLabel.name === '' ? JSON.parse(localStorage.getItem('mapPosition')).code : this.cityLabel.code,
                        dataType: formatAppData.tabs.data[0].indexTab,
                        mapGroupBy: 'opportunity_city_id'
                    },
                    id: formatId,
                    sessionId: localStorage.getItem('sessionId')
                };
                this.httpService.post('application/submit', params, (res) => {
                    if (res) {
                        if (typeof res.data.data !== 'string') {
                            that.tagData.appDataMapList.data = res.data.data;
                        } else {
                            that.tagData.appDataMapList.data = JSON.parse(res.data.data);
                        }
                        that.formatCityData.infoList = that.tagData.appDataMapList.data.infoList;
                        that.formatCityData.stateTabs = that.tagData.appDataMapList.data.stateTabs;
                        that.formatCityData.statistics = that.tagData.appDataMapList.data.statistics;
                        that.initMap(pt);
                    }
                });
            });
            tab2.onclick = ((e) => {
                tab2.style.border = "0.03rem solid rgba(255,99,20,1)";
                tab1.style.border = "0rem";
                if (this.appTypeCustom === 'LJ') {
                    pShop.style.color = "#575A61";
                    pSiting.style.color = "#946C00";
                    tab2.style.background = 'rgba(255, 202, 58, 0.1)';
                    tab1.style.background = '#ffffff';
                } else {
                    pShop.style.color = "rgba(92,94,102,1)";
                    pSiting.style.color = "rgba(255,99,20,1)";
                    tab2.style.background = '#ffffff';
                    tab1.style.background = '#ffffff';
                }
                const params = {
                    content: {
                        level: "city",
                        dataType: formatAppData.tabs.data[1].indexTab,
                        code: this.cityLabel.name === '' ? JSON.parse(localStorage.getItem('mapPosition')).code : this.cityLabel.code,
                        mapGroupBy: 'opportunity_expect_district',
                    },
                    id: formatId,
                    sessionId: localStorage.getItem('sessionId')
                };
                this.httpService.post('application/submit', params, (res) => {
                    if (res) {
                        if (typeof res.data.data !== 'string') {
                            that.tagData.appDataMapList.data = res.data.data;
                        } else {
                            that.tagData.appDataMapList.data = JSON.parse(res.data.data);
                        }
                        that.formatCityData.infoList = that.tagData.appDataMapList.data.infoList;
                        that.formatCityData.stateTabs = that.tagData.appDataMapList.data.stateTabs;
                        that.formatCityData.statistics = that.tagData.appDataMapList.data.statistics;
                        that.initMap(pt);
                    }
                });
            });
            div.appendChild(tab1);
            div.appendChild(tab2);
            div.style.width = "6rem";
            div.style.height = "2.25rem";
            if (this.appTypeCustom === 'LJ') {
                div.style.boxShadow = "0rem 0.06rem 0.25rem 0rem rgba(37, 38, 41, 0.1)";
            } else {
                div.style.boxShadow = "0rem 0.06rem 0.25rem 0rem rgba(39,40,46,0.1)";
            }
            div.style.background = "rgba(255,255,255,1)";
            div.style.borderRadius = "0.31rem";
            map.getContainer().appendChild(div);
            return div;
        };
        const tabs = new showTabTransferSitingControl();
        const list = new showListControl();
        const locationBtn = new showLocationControl();
        if (formatAppData !== undefined && formatAppData.tabs !== undefined) { map.addControl(tabs); } else { map.removeControl(tabs); }
        map.addControl(list);
        map.addControl(locationBtn);
        let isEnlarge = false;
        let switchLevel = 0;
        map.addEventListener("zoomstart", () => {
            switchLevel = 0;
            const mapLevel = map.getZoom();
            switchLevel = mapLevel;
        });
        map.addEventListener("zoomend", () => {
            const mapLevel = map.getZoom();
            isEnlarge = mapLevel > switchLevel;
            if (mapLevel >= 5 && mapLevel <= 9) {
                that.dataLevel = "province"; that.chartCenterLabel.nativeElement.innerHTML = "全国";
                if (that.numberCtrlElement !== undefined) { that.numberCtrlElement.nativeElement.style.display = "block"; }
                if (mapLevel >= 7 && mapLevel <= 9 && that.formatProvinceData.infoList && that.formatProvinceData.infoList.length > 0) {
                    map.clearOverlays();
                    map.disableDoubleClickZoom();
                    map.disableContinuousZoom();
                    map.enableScrollWheelZoom();
                    map.enableInertialDragging();
                    if (that.countCtrlElement !== undefined) { that.countCtrlElement.nativeElement.style.display = "none"; }
                    that.updateAppDataMapList(that.formatProvinceData);
                    that.refreshProvinceData(map);
                } else {
                    const pStore = JSON.parse(localStorage.getItem('mapPosition'));
                    that.chartCenterLabel.nativeElement.innerHTML = "全国";
                    if (that.countCtrlElement !== undefined) {
                        that.countCtrlElement.nativeElement.style.display = "none";
                    }
                    document.getElementById('shopDetailCtrl').style.display = "none";
                    document.getElementById('subTabsCtrl').style.display = "block";
                    map.clearOverlays();
                    map.enableScrollWheelZoom();
                    if (that.formatCountryData !== undefined && that.formatCountryData.infoList.length > 0 || mapLevel < 7) {
                        that.checkLevelProvinceData(map);
                    } else {
                        that.map.clearOverlays();
                        const provinceCode = (pStore.code + '').substring(0, 2);
                        const params = {
                            content: { level: "city", code: provinceCode, dataType: dataTransferType },
                            id: formatId, sessionId: localStorage.getItem('sessionId')
                        };
                        this.httpService.post('application/submit', params, (res) => {
                            if (res) {
                                if (typeof res.data.data !== 'string') {
                                    that.formatProvinceData = res.data.data;
                                } else {
                                    that.formatProvinceData = JSON.parse(res.data.data);
                                }
                                that.updateAppDataMapList(that.formatProvinceData);
                                that.refreshProvinceData(map);
                            }
                        });
                    }
                }
            } else if (mapLevel > 9 && mapLevel < 11) {
                that.chartCenterLabel.nativeElement.innerHTML = "全国";
                if (switchLevel === 9 && isEnlarge) {
                    map.zoomOut();
                } else if (switchLevel === 11 && !isEnlarge) {
                    map.enableScrollWheelZoom();
                    if (that.formatProvinceData.infoList.length === 0) {
                        const provinceCode = (that.formatCityData.infoList[0].code + '').substring(0, 2);
                        const params = {
                            content: {
                                level: "city",
                                code: provinceCode,
                                dataType: dataTransferType
                            },
                            id: that.formatCityData.infoList[0].id,
                            sessionId: localStorage.getItem('sessionId')
                        };
                        this.httpService.post('application/submit', params, (res) => {
                            if (res) {
                                if (typeof res.data.data !== 'string') {
                                    that.formatProvinceData = res.data.data;
                                } else {
                                    that.formatProvinceData = JSON.parse(res.data.data);
                                }
                                that.cityZoomToProvince(map);
                            }
                        });
                    } else { that.cityZoomToProvince(map); }
                }
            } else if (mapLevel >= 11 && mapLevel <= 13) {
                if (that.countCtrlElement !== undefined) { that.countCtrlElement.nativeElement.style.display = "block"; }
                that.dataLevel = "city";
                map.clearOverlays();
                document.getElementById('shopDetailCtrl').style.display = "none";
                document.getElementById('subTabsCtrl').style.display = "block";
                map.enableScrollWheelZoom();
                map.disableDoubleClickZoom();
                map.disableContinuousZoom();
                map.disableInertialDragging();
                if (that.formatCityData.infoList.length > 0) { that.refreshLevelCityData(map); } else { that.checkLevelCityData(map); }
            } else if (mapLevel >= 14 && mapLevel <= 15) {
                that.dataLevel = "district";
                map.clearOverlays();
                document.getElementById('shopDetailCtrl').style.display = "none";
                document.getElementById('subTabsCtrl').style.display = "block";
                map.disableDoubleClickZoom();
                map.enableScrollWheelZoom();
                map.disableContinuousZoom();
                map.disableInertialDragging();
                that.checkLevelDistrictData(map);
            } else if (mapLevel >= 16 && mapLevel <= 21) {
                that.dataLevel = "point";
                map.clearOverlays();
                document.getElementById('shopDetailCtrl').style.display = "none";
                document.getElementById('subTabsCtrl').style.display = "block";
                map.disableDoubleClickZoom();
                map.enableScrollWheelZoom();
                map.disableContinuousZoom();
                map.disableInertialDragging();
                that.checkLevelPointData(map);
            }
        });
        map.addEventListener("tilesloaded", () => {
            const objs = document.getElementsByClassName(" anchorBL");
            if (objs !== undefined && objs.length > 0) {
                for (let i = 0, len = objs.length; i < len; i++) {
                    if (objs[i] !== undefined) { objs[i].setAttribute("style", "display:none;"); }
                }
            }
        });
        map.addEventListener("dragstart", () => {
            const pStore = JSON.parse(localStorage.getItem('mapPosition'));
            const mapLevel = map.getZoom();
            if (mapLevel >= 13) {
                const geoc = new BMap.Geocoder();
                const center = map.getCenter();
                const pt = new BMap.Point(center.lng, center.lat);
                geoc.getLocation(pt, rs => {
                    const cityName = rs.addressComponents.city;
                    const tName = pStore.name;
                    if (cityName.toString().indexOf(tName) < 0) {
                        that.appGlobalService.showToast('请缩小地图再查看其他城市数据', 1000, "middle");
                    }
                });
            }
        });
        if (formatAppData.level === 'province') {
            that.dataLevel = 'province';
            that.chartCenterLabel.nativeElement.innerHTML = "全国";
            const provinceAreaPoint = new BMap.Point(114.335148, 15.75169);
            const provinceAreaLevel = 5;
            map.centerAndZoom(provinceAreaPoint, provinceAreaLevel);
            that.formatCountryData.infoList = formatInfoList;
            that.checkLevelCountryData(map);
        } else if (formatAppData.level === 'city') {
            that.dataLevel = 'city';
            map.enableScrollWheelZoom();
            if (that.cityLabel.name !== '') {
                that.dataLevelCode = that.cityLabel.code;
                that.currentClickPt.longitude = that.cityLabel.longitude;
                that.currentClickPt.latitude = that.cityLabel.latitude;
                that.chartCenterLabel.nativeElement.innerHTML = that.cityLabel.name;
                that.chooseCityName = that.cityLabel.name;
                map.centerAndZoom(new BMap.Point(that.cityLabel.longitude, that.cityLabel.latitude), 11);
            } else {
                const pStore = JSON.parse(localStorage.getItem('mapPosition'));
                const localCityName = pStore.name;
                that.dataLevelCode = pStore.code;
                that.currentClickPt.longitude = pStore.center.lng;
                that.currentClickPt.latitude = pStore.center.lat;
                that.chartCenterLabel.nativeElement.innerHTML = localCityName;
                that.chooseCityName = localCityName;
                map.centerAndZoom(new BMap.Point(pStore.center.lng, pStore.center.lat), 11);
            }
            if (formatAppData.code !== undefined && formatAppData.code.length > 0) {
                that.formatCityData.infoList = formatAppData.infoList;
                that.formatCityData.statistics = formatAppData.statistics;
                that.formatCityData.stateTabs = formatAppData.stateTabs;
            } else {
                that.formatCountryData.infoList = formatAppData.infoList;
                that.formatCountryData.statistics = formatAppData.statistics;
                that.formatCountryData.stateTabs = formatAppData.stateTabs;
            }
        } else if (formatAppData.level === 'district') {
            that.formatDistrictData.infoList = that.tagData.appDataMapList.data.infoList;
            that.formatDistrictData.stateTabs = that.tagData.appDataMapList.data.stateTabs;
            that.formatDistrictData.statistics = that.tagData.appDataMapList.data.statistics;
            that.dataLevel = 'district';
            map.enableScrollWheelZoom();
            map.centerAndZoom(new BMap.Point(that.currentClickPt.longitude, that.currentClickPt.latitude), 14);
            that.checkLevelDistrictData(map);
        } else if (formatAppData.level === 'point') {
            that.dataLevel = 'point';
            map.enableScrollWheelZoom();
            map.centerAndZoom(new BMap.Point(that.currentClickPt.longitude, that.currentClickPt.latitude), 16);
            if (that.formatPointData.infoList.length > 0) { that.refreshLevelPointData(map); } else { that.checkLevelPointData(map); }
        }
    }
    cityZoomToProvince(mapref) {
        const that = this;
        that.updateAppDataMapList(that.formatProvinceData);
        const lat = parseFloat(that.formatProvinceData.infoList[0].latitude + '');
        that.chartCenterLabel.nativeElement.innerHTML = that.formatProvinceData.infoList[0].name;
        mapref.centerAndZoom(new BMap.Point(that.formatProvinceData.infoList[0].longitude, lat), 9);
    }
    checkLevelCountryData(mapRef) {
        const that = this;
        const markers = [];
        for (let i = 0, len = that.formatCountryData.infoList.length; i < len; i++) {
            markers[i] = new BMap.Marker(
                new BMap.Point(that.formatCountryData.infoList[i].longitude,
                    that.formatCountryData.infoList[i].latitude), { icon: that.provinceIcon });
            markers[i].addEventListener("click", e => {
                that.dataLevelCode = that.formatCountryData.infoList[i].code;
                that.dataLevelLabel = that.formatCountryData.infoList[i].name;
                that.currentClickPt.longitude = that.formatCountryData.infoList[i].longitude;
                that.currentClickPt.latitude = that.formatCountryData.infoList[i].latitude;
                const params = {
                    content: {
                        level: "city",
                        code: that.formatCountryData.infoList[i].code,
                        dataType: that.dataType
                    },
                    id: that.formatCountryData.infoList[i].id,
                    sessionId: localStorage.getItem('sessionId')
                };
                this.httpService.post('application/submit', params, (res) => {
                    if (res) {
                        let tempInfo = { infoList: [], statistics: [], stateTabs: {} };
                        if (typeof res.data.data !== 'string') {
                            tempInfo = res.data.data;
                        } else {
                            tempInfo = JSON.parse(res.data.data);
                        }
                        if (tempInfo.infoList && tempInfo.infoList.length > 0) {
                            that.formatProvinceData = JSON.parse(res.data.data);
                            that.updateAppDataMapList(that.formatProvinceData);
                            that.refreshIndustryStateData();
                            const lat = parseFloat(that.formatCountryData.infoList[i].latitude + '');
                            mapRef.centerAndZoom(new BMap.Point(that.formatCountryData.infoList[i].longitude, lat), 9);
                        }
                    }
                });
            });
            mapRef.addOverlay(markers[i]);
        }
        const pStore = JSON.parse(localStorage.getItem('mapPosition')); const marker = new BMap.Marker(new BMap.Point(pStore.center.lng, pStore.center.lat), { icon: that.locationIcon }); mapRef.addOverlay(marker);
    }
    checkLevelProvinceData(mapRef) {
        const that = this;
        that.map.clearOverlays();
        const params = { content: { level: "province", dataType: that.dataType }, id: that.contextFormId, sessionId: localStorage.getItem('sessionId') };
        this.httpService.post('application/submit', params, (res) => {
            if (res) {
                if (typeof res.data.data !== 'string') {
                    that.formatCountryData = res.data.data;
                } else {
                    that.formatCountryData = JSON.parse(res.data.data);
                }
                that.updateAppDataMapList(that.formatCountryData);
                that.refreshIndustryStateData();
                that.checkLevelCountryData(mapRef);
            }
        });
    }
    checkLevelCityData(mapRef) {
        const that = this;
        const pStore = JSON.parse(localStorage.getItem('mapPosition'));
        const params = { content: { level: "city", code: pStore.code, dataType: that.dataType, mapGroupBy: 'opportunity_city_id' }, id: that.contextFormId, sessionId: localStorage.getItem('sessionId') };
        this.httpService.post('application/submit', params, (res) => {
            if (res) {
                if (typeof res.data.data !== 'string') {
                    that.formatCityData = res.data.data;
                } else {
                    that.formatCityData = JSON.parse(res.data.data);
                }
                that.updateAppDataMapList(that.formatCityData);
                that.refreshLevelCityData(mapRef);
            }
        });
    }
    checkLevelDistrictData(mapRef) {
        const that = this;
        if (that.numberCtrlElement) {
            that.numberCtrlElement.nativeElement.style.display = that.numberCtrlElement !== undefined ? "block" : "none";
        }
        if (that.countCtrlElement !== undefined) { that.countCtrlElement.nativeElement.style.display = "block"; }
        that.updateAppDataMapList(that.formatDistrictData);
        that.refreshIndustryStateData();
        const cAmarks = [];
        for (let i = 0, len = that.formatDistrictData.infoList.length; i < len; i++) {
            let lblStringNew = "";
            if (this.appTypeCustom === 'LJ') {
                lblStringNew = "<div align='center' style='line-height:1.54rem;height: 1.54rem;background:#FFCA3A;box-shadow:0px 2px 5px 0px rgba(39,40,46,0.1);border-radius:23px;opacity:0.94;padding-left:13px;padding-right:13px;'>"
                    + "<p>" + that.formatDistrictData.infoList[i].name + " " + that.formatDistrictData.infoList[i].number + "</p>"
                    + "<img src='assets/laijian/map/map_arrow_nor@3x.png' style='width:8px;margin-top: -1.3rem;'></img></div>";
            } else {

                lblStringNew = "<div align='center' style='line-height:1.54rem;height: 1.54rem;background:rgba(255,99,20,1);box-shadow:0px 2px 5px 0px rgba(39,40,46,0.1);border-radius:23px;opacity:0.94;padding-left:13px;padding-right:13px;'>"
                    + "<p>" + that.formatDistrictData.infoList[i].name + " " + that.formatDistrictData.infoList[i].number + "</p>"
                    + "<img src='assets/img/map/map_arrow_nor@3x.png' style='width:8px;margin-top: -1.3rem;'></img></div>";
            }
            cAmarks[i] =
                new BMap.Marker(
                    new BMap.Point(that.formatDistrictData.infoList[i].longitude, that.formatDistrictData.infoList[i].latitude), {
                    icon: that.districtOp
                }
                );
            const label = new BMap.Label(lblStringNew, { offset: new BMap.Size(0, 0) });
            label.setStyle({
                fontSize: "12px",
                color: "#fff",
                border: "none",
                backgroundColor: "transparent"
            });
            cAmarks[i].setLabel(label);
            cAmarks[i].addEventListener("click", e => {
                that.dataLevelCode = that.formatDistrictData.infoList[i].code;
                that.dataLevelLabel = that.formatDistrictData.infoList[i].name;
                that.currentClickPt.longitude = that.formatDistrictData.infoList[i].longitude;
                that.currentClickPt.latitude = that.formatDistrictData.infoList[i].latitude;
                const bs = this.map.getBounds();
                const bsne = bs.getNorthEast();
                const bssw = bs.getSouthWest();
                const params = { content: { level: "district", code: that.formatDistrictData.infoList[i].code, dataType: that.dataType, mapGroupBy: this.getGroupByStr(), location: { content: { ll1: { longitude: bsne.lng, latitude: bsne.lat }, ll2: { longitude: bs.Ge, latitude: bs.Yd }, ll3: { longitude: bs.Le, latitude: bs.Wd }, ll4: { longitude: bssw.lng, latitude: bssw.lat } } } }, id: that.formatDistrictData.infoList[i].id, sessionId: localStorage.getItem('sessionId') };
                this.httpService.post('application/submit', params, (res) => {
                    if (res) {
                        if (typeof res.data.data !== 'string') {
                            that.formatPointData = res.data.data;
                        } else {
                            that.formatPointData = JSON.parse(res.data.data);
                        }
                        that.chartCenterLabel.nativeElement.innerHTML = that.formatDistrictData.infoList[i].name;
                        that.updateAppDataMapList(that.formatPointData);
                        that.refreshIndustryStateData();
                        mapRef.centerAndZoom(new BMap.Point(that.formatDistrictData.infoList[i].longitude
                            , that.formatDistrictData.infoList[i].latitude), 16);
                    } else {
                    }
                });
            });
            mapRef.addOverlay(cAmarks[i]);
        }
    }
    checkLevelPointData(mapRef) {
        const that = this;
        const bs = this.map.getBounds();
        const bsne = bs.getNorthEast();
        const bssw = bs.getSouthWest();
        const params = { content: { level: "point", code: that.dataLevelCode, dataType: that.dataType, mapGroupBy: this.getGroupByStr(), location: { content: { ll1: { longitude: bsne.lng, latitude: bsne.lat }, ll2: { longitude: bs.Ge, latitude: bs.Yd }, ll3: { longitude: bs.Le, latitude: bs.Wd }, ll4: { longitude: bssw.lng, latitude: bssw.lat } } } }, id: that.contextFormId, sessionId: localStorage.getItem('sessionId') };
        this.httpService.post('application/submit', params, (res) => {
            if (res) {
                if (typeof res.data.data !== 'string') {
                    that.formatPointData = res.data.data;
                } else {
                    that.formatPointData = JSON.parse(res.data.data);
                }
                that.refreshLevelPointData(mapRef);
            }
        });
    }
    refreshProvinceData(mapRef) {
        this.refreshIndustryStateData();
        const that = this;
        const pmarkers = [];
        const prLength = that.formatProvinceData.infoList.length;
        for (let i = 0; i < prLength; i++) {
            let lblStringNew = "";
            if (this.appTypeCustom === 'LJ') {
                lblStringNew = "<div align='center' style='line-height:1.54rem;height: 1.54rem;background:#FFCA3A;box-shadow:0px 2px 5px 0px rgba(39,40,46,0.1);border-radius:23px;opacity:0.94;padding-left:13px;padding-right:13px;'>"
                    + "<p>" + that.formatProvinceData.infoList[i].name + "</p>"
                    + "<img src='assets/laijian/map/map_arrow_nor@3x.png' style='width:8px;margin-top: -1.3rem;'></img></div>";
            } else {

                lblStringNew = "<div align='center' style='line-height:1.54rem;height: 1.54rem;background:rgba(255,99,20,1);box-shadow:0px 2px 5px 0px rgba(39,40,46,0.1);border-radius:23px;opacity:0.94;padding-left:13px;padding-right:13px;'>"
                    + "<p>" + that.formatProvinceData.infoList[i].name + "</p>"
                    + "<img src='assets/img/map/map_arrow_nor@3x.png' style='width:8px;margin-top: -1.3rem;'></img></div>";
            }
            pmarkers[i] =
                new BMap.Marker(
                    new BMap.Point(that.formatProvinceData.infoList[i].longitude,
                        that.formatProvinceData.infoList[i].latitude),
                    { icon: that.cityOp });
            const label = new BMap.Label(lblStringNew, { offset: new BMap.Size(0, 0) });
            label.setStyle({
                fontSize: "12px",
                color: "#fff",
                border: "none",
                background: "none"
            });
            pmarkers[i].setLabel(label);
            pmarkers[i].addEventListener("click", e => {
                that.dataLevelCode = that.formatProvinceData.infoList[i].code; that.dataLevelLabel = that.formatProvinceData.infoList[i].name; that.cityLabel.name = that.formatProvinceData.infoList[i].name; that.cityLabel.code = that.formatProvinceData.infoList[i].code; that.cityLabel.longitude = that.formatProvinceData.infoList[i].longitude; that.cityLabel.latitude = that.formatProvinceData.infoList[i].longitude;
                const cparams = { content: { level: "city", code: that.formatProvinceData.infoList[i].code, dataType: that.dataType, mapGroupBy: 'opportunity_city_id' }, id: that.formatProvinceData.infoList[i].id, sessionId: localStorage.getItem('sessionId') };
                this.httpService.post('application/submit', cparams, (pres) => {
                    if (pres) {
                        if (typeof pres.data.data !== 'string') {
                            that.formatCityData = pres.data.data;
                        } else {
                            that.formatCityData = JSON.parse(pres.data.data);
                        }
                        that.updateAppDataMapList(that.formatCityData);
                        const long = that.formatCityData.infoList[i].longitude;
                        const lat = that.formatCityData.infoList[i].latitude;
                        that.chartCenterLabel.nativeElement.innerHTML = that.formatProvinceData.infoList[i].name;
                        that.currentClickPt.longitude = long;
                        that.currentClickPt.latitude = lat;
                        mapRef.centerAndZoom(new BMap.Point(long, lat), 11);
                    }
                });
            });
            mapRef.addOverlay(pmarkers[i]);
        }
        const pStore = JSON.parse(localStorage.getItem('mapPosition')); const marker = new BMap.Marker(new BMap.Point(pStore.center.lng, pStore.center.lat), { icon: that.locationIcon }); mapRef.addOverlay(marker);
    }
    refreshLevelCityData(mapRef) {
        const that = this;
        that.refreshIndustryStateData();
        if (that.numberCtrlElement && that.numberCtrlElement.nativeElement) {
            that.numberCtrlElement.nativeElement.style.display = that.numberCtrlElement ? "block" : "none";
        }
        if (that.countCtrlElement !== undefined) { that.countCtrlElement.nativeElement.style.display = "block"; }
        const cDmarks = [];
        const len = that.formatCityData.infoList.length;
        for (let i = 0; i < len; i++) {
            let lblStringNew = "";
            if (this.appTypeCustom === 'LJ') {
                lblStringNew = "<div align='center' style='line-height:1.54rem; height: 1.54rem;background:#FFCA3A;box-shadow:0px 2px 5px 0px rgba(39,40,46,0.1);border-radius:23px;opacity:0.94;padding-left:13px;padding-right:13px;'>"
                    + "<p>" + that.formatCityData.infoList[i].name + " " + that.formatCityData.infoList[i].number + "</p>"
                    + "<img src='assets/laijian/map/map_arrow_nor@3x.png' style='width:8px;margin-top: -1.3rem;'></img></div>";
            } else {
                lblStringNew = "<div align='center' style='line-height:1.54rem; height: 1.54rem;background:rgba(255,99,20,1);box-shadow:0px 2px 5px 0px rgba(39,40,46,0.1);border-radius:23px;opacity:0.94;padding-left:13px;padding-right:13px;'>"
                    + "<p>" + that.formatCityData.infoList[i].name + " " + that.formatCityData.infoList[i].number + "</p>"
                    + "<img src='assets/img/map/map_arrow_nor@3x.png' style='width:8px;margin-top: -1.3rem;'></img></div>";
            }
            cDmarks[i] = new BMap.Marker(
                new BMap.Point(that.formatCityData.infoList[i].longitude,
                    that.formatCityData.infoList[i].latitude), { icon: that.districtOp });
            const label = new BMap.Label(lblStringNew, { offset: new BMap.Size(0, 0) });
            label.setStyle({
                fontSize: "12px",
                color: "#fff",
                border: "none",
                backgroundColor: "transparent"
            });
            cDmarks[i].setLabel(label);
            cDmarks[i].addEventListener("click", e => {
                that.dataLevelCode = that.formatCityData.infoList[i].code;
                that.dataLevelLabel = that.formatCityData.infoList[i].name;
                that.currentClickPt.longitude = that.formatCityData.infoList[i].longitude;
                that.currentClickPt.latitude = that.formatCityData.infoList[i].latitude;
                const subParams = { content: { level: "district", code: that.formatCityData.infoList[i].code, dataType: that.dataType, mapGroupBy: this.getGroupByStr() }, id: that.formatCityData.infoList[i].id, sessionId: localStorage.getItem('sessionId') };
                this.httpService.post('application/submit', subParams, (subRes) => {
                    if (subRes) {
                        if (typeof subRes.data.data !== 'string') {
                            that.formatDistrictData = subRes.data.data;
                        } else {
                            that.formatDistrictData = JSON.parse(subRes.data.data);
                        }
                        that.updateAppDataMapList(that.formatDistrictData);
                        that.refreshIndustryStateData();
                        that.chartCenterLabel.nativeElement.innerHTML = that.formatCityData.infoList[i].name;
                        mapRef.centerAndZoom(new BMap.Point(that.formatCityData.infoList[i].longitude,
                            that.formatCityData.infoList[i].latitude), 14);
                    }
                });
            });
            mapRef.addOverlay(cDmarks[i]);
        }
    }
    refreshLevelPointData(mapRef) {
        const that = this;
        if (that.numberCtrlElement !== undefined) {
            that.numberCtrlElement.nativeElement.style.display = that.numberCtrlElement !== undefined ? "block" : "none";
        }
        if (that.countCtrlElement !== undefined) { that.countCtrlElement.nativeElement.style.display = "block"; }
        that.updateAppDataMapList(that.formatPointData);
        that.refreshIndustryStateData();
        const long = parseFloat(this.localPoint.lng + '');
        const lat = parseFloat(this.localPoint.lat + '');
        const marker = new BMap.Marker(new BMap.Point(long, lat), { icon: that.locationIcon });
        mapRef.addOverlay(marker);
        const pmarks = [];
        let statePng = new BMap.Icon("/assets/img/map/11.png", new BMap.Size(40, 45));
        const path = (this.appTypeCustom === 'LJ' ? "/assets/laijian/map/" : "/assets/img/map/");
        for (let i = 0, len = that.formatPointData.infoList.length; i < len; i++) {
            const idx = (that.formatPointData.infoList[i].industryType + '').substring(0, 2);
            const url = path + idx;
            if (idx !== '-') {
                statePng = new BMap.Icon(url + ".png", new BMap.Size(40, 45));
            }
            if (that.formatPointData.infoList[i].longitude !== undefined
                && that.formatPointData.infoList[i].latitude !== undefined) {
                pmarks[i] = new BMap.Marker(
                    new BMap.Point(that.formatPointData.infoList[i].longitude,
                        that.formatPointData.infoList[i].latitude),
                    { icon: statePng });
                pmarks[i].addEventListener("click", e => {
                    if (that.shopMark !== undefined) {
                        if (pmarks[that.shopMark.i] !== undefined) {
                            const purl = pmarks[that.shopMark.i].getIcon().imageUrl.replace("_0", "_1");
                            pmarks[that.shopMark.i].setIcon(new BMap.Icon(purl, new BMap.Size(40, 45)));
                            that.formatPointData.infoList[that.shopMark.i].stClick = undefined;
                        }
                    }
                    that.shopMark = pmarks[i];
                    that.shopMark.i = i;
                    if (that.formatPointData.infoList[i].stClick !== undefined) {
                        pmarks[i].setIcon(new BMap.Icon(url + ".png", new BMap.Size(40, 45)));
                        document.getElementById('shopDetailCtrl').style.display = "none";
                        document.getElementById('subTabsCtrl').style.display = "none";
                        that.formatPointData.infoList[i].stClick = undefined;
                    } else {
                        that.formatPointData.infoList[i].stClick = '0';
                        pmarks[i].setIcon(new BMap.Icon(url + "_0.png", new BMap.Size(40, 45)));
                        document.getElementById('subTabsCtrl-div3').style.display = "none";
                        document.getElementById('shopDetailCtrl').style.display = "block";
                        document.getElementById('subTabsCtrl').style.display = "none";
                        document.getElementById('detailInfoTitle').innerHTML = that.formatPointData.infoList[i].title;
                        document.getElementById('detailInfoPic').setAttribute('src', that.formatPointData.infoList[i].images.imageUrl);
                        document.getElementById('detailInfoExtend').innerHTML = that.formatPointData.infoList[i].info;
                        document.getElementById('detailInfoPoints').innerHTML
                            = that.formatPointData.infoList[i].points === undefined ?
                                "未知" : that.formatPointData.infoList[i].points;
                        document.getElementById('detailInfoRent').innerHTML = that.formatPointData.infoList[i].rent;
                        document.getElementById('detailInfoTimes').innerHTML = that.formatPointData.infoList[i].times;
                        const targetObj = {
                            pageId: that.formatPointData.infoList[i].link.target,
                            params: that.formatPointData.infoList[i].link.params,
                            sessionId: localStorage.getItem('sessionId')
                        };
                        document.getElementById("detailInfo_targetObj").innerHTML = JSON.stringify(targetObj);
                    }
                });
                mapRef.addOverlay(pmarks[i]);
            }
        }
    }
    showFilterModel() {
        const coverDiv = document.getElementById('map-filter-cover'); const filterBox = document.getElementById('map-filter-box');
        if (coverDiv.style.display === "none") { coverDiv.style.display = "block"; filterBox.style.display = "block"; } else {
            coverDiv.style.display = "none"; filterBox.style.display = "none";
        }
    }
    submitFilterParam() {
        if (this.keyword === '' && this.industryBean.value === 0 && this.areaBean.value === 0) {
            this.appGlobalService.showToast("请输入筛选条件", 1000, "top"); return;
        }
        const bs = this.map.getBounds();
        const bsne = bs.getNorthEast();
        const bssw = bs.getSouthWest();
        const params = { content: { level: this.dataLevel, code: this.dataLevelCode, dataType: this.dataType, mapGroupBy: this.dataLevel === 'city' ? 'opportunity_city_id' : 'opportunity_district_id', location: { content: { ll1: { longitude: bsne.lng, latitude: bsne.lat }, ll2: { longitude: bs.Ge, latitude: bs.Yd }, ll3: { longitude: bs.Le, latitude: bs.Wd }, ll4: { longitude: bssw.lng, latitude: bssw.lat } } }, keyword: this.keyword, industryList: this.industryBean.value, areaList: this.areaBean.value, }, id: this.contextFormId, sessionId: localStorage.getItem('sessionId') };
        this.httpService.post('application/submit', params, (res) => {
            if (res) {
                if (typeof res.data.data !== 'string') {
                    this.tagData.appDataMapList.data = res.data.data;
                } else {
                    this.tagData.appDataMapList.data = JSON.parse(res.data.data);
                }
            }
            document.getElementById('useForBlur').blur();
        });
        this.showFilterModel();
    }
    onOk2Industry(result, item) {
        if (result.length && isArray(result)) { item.value = result[1].code; item.checkLabel = `${result[1].label}`; }
    }
    onOk2Area(result, item) {
        if (result.length && isArray(result)) { item.value = result[0].code; item.checkLabel = `${result[0].label}`; }
    }

    closePic() { const that = this; if (that.shopMark) { that.formatPointData.infoList[that.shopMark.i].stClick = undefined; const imgUrl = that.shopMark.getIcon().imageUrl.toString().replace('_0', ''); that.shopMark.setIcon(new BMap.Icon(imgUrl, new BMap.Size(40, 45))); } document.getElementById('subTabsCtrl').style.display = "block"; document.getElementById('shopDetailCtrl').style.display = "none"; } // document.getElementById('sNumberCount').style.top = "277px";
    gotoDetailPage() {
        const targetObj = JSON.parse(document.getElementById("detailInfo_targetObj").innerHTML);
        this.appGlobalService.goToForward(targetObj);
    }
    subTabsClick(type) {
        this.subTabsState = type;
        document.getElementById('subTabsCtrl-div1-p1').style.color = type === 1 ? "rgba(39,40,46,1)" : "rgba(133,136,148,1)";
        document.getElementById('subTabsCtrl-div1-p1').style.fontWeight = type === 1 ? "bold" : "normal";
        document.getElementById('subTabsCtrl-div1-p2').style.color = type === 1 ? "rgba(133,136,148,1)" : "rgba(39,40,46,1)";
        document.getElementById('subTabsCtrl-div1-p2').style.fontWeight = type === 1 ? "normal" : "bold";
        document.getElementById('subTabs-infoD1').style.display = type === 1 ? "block" : "none";
        document.getElementById('subTabs-infoD2').style.display = type === 1 ? "none" : "block";
        document.getElementById('subTabsCtrl-div3').style.display = type === 1 ? "none" : "flex";
    }
    iPrevious() {
        if ((this.industryCurrPageNum - 1) < 0) { return; } else {
            this.industryCurrPageNum--;
            this.industryDataArray =
                this.tagData.appDataMapList.data.stateTabs.data[1]
                    .content.slice(this.industryCurrPageNum * 4, this.industryCurrPageNum * 4 + this.industryDataPageSize);
        }
    }
    iNext() {
        let totalPageSize;
        const countNumber = (this.tagData.appDataMapList.data.stateTabs.data[1].content.length / 4);
        if (countNumber > parseInt(countNumber + '')) {
            totalPageSize = parseInt(countNumber + '') + 1;
        } else { totalPageSize = parseInt(countNumber + ''); }
        if ((this.industryCurrPageNum + 1) > (totalPageSize - 1)) {
            return;
        } else {
            this.industryCurrPageNum++;
            this.industryDataArray =
                this.tagData.appDataMapList.data.stateTabs.data[1]
                    .content.slice(this.industryCurrPageNum * 4, this.industryCurrPageNum * 4 + this.industryDataPageSize);
        }
    }
    refreshIndustryStateData() {
        const that = this;
        if (that.tagData.appDataMapList.data.industryList !== undefined) {
            that.tagData.appDataMapList.data.industryList = that.tagData.appDataMapList.data.industryList.toString().substring(0, 2);
        }
        if (that.tagData.appDataMapList.data.stateTabs.data && that.tagData.appDataMapList.data.stateTabs.data[1] !== undefined) {
            if (that.tagData.appDataMapList.data.stateTabs.data[1].content.length < 4) {
                that.industryDataArray = that.tagData.appDataMapList.data.stateTabs.data[1].content;
            } else {

                that.industryDataArray = that.tagData.appDataMapList.data.stateTabs.data[1].content.slice(this.industryCurrPageNum * 4, this.industryCurrPageNum * 4 + this.industryDataPageSize);
            }
        }
        if (that.tagData.appDataMapList.data.stateTabs.data && that.tagData.appDataMapList.data.stateTabs.data[0] !== undefined) {
            if (that.tagData.appDataMapList.data.stateTabs.data[0].content.length < 4) {
                that.stateDataArray = that.tagData.appDataMapList.data.stateTabs.data[0].content;
            } else {
                that.stateDataArray = that.tagData.appDataMapList.data.stateTabs.data[0].content.slice(0, 4);
            }
        }
    }
    stateClick(type, len) {
        const mapLevel = this.map.getZoom();
        for (let i = 0; i < len; i++) {
            if (type === i && mapLevel >= 11) {
                this.transferRentState = type;
                const params = this.dataType === 1 ? { content: { level: this.dataLevel, code: this.dataLevelCode, dataType: this.dataType, showName: this.transferRentState === 0 ? "#opportunity_transfer" : "#opportunity_rent", opportunity_plugin_id: this.transferRentState === 0 ? 1 : 2, mapGroupBy: this.dataLevel === 'city' ? 'opportunity_city_id' : 'opportunity_district_id', keyword: this.keyword, industryList: this.industryBean.value, areaList: this.areaBean.value, }, id: this.contextFormId, sessionId: localStorage.getItem('sessionId') } : { content: { level: this.dataLevel, opportunity_expect_district: this.dataLevelCode, dataType: this.dataType, showName: this.transferRentState === 0 ? "#opportunity_transfer" : "#opportunity_rent", opportunity_plugin_id: 3, mapGroupBy: 'opportunity_expect_city', keyword: this.keyword, industryList: this.industryBean.value, areaList: this.areaBean.value, }, id: this.contextFormId, sessionId: localStorage.getItem('sessionId') };
                this.httpService.post('application/submit', params, async (res) => {
                    if (res) {
                        if (typeof res.data.data !== 'string') {
                            this.tagData.appDataMapList.data = res.data.data;
                        } else {
                            this.tagData.appDataMapList.data = await JSON.parse(res.data.data);
                        }
                        if (this.tagData.appDataMapList.data.level === 'city') {
                            this.formatCityData.infoList = this.tagData.appDataMapList.data.infoList;
                            this.formatCityData.statistics = this.tagData.appDataMapList.data.statistics;
                            this.formatCityData.stateTabs = this.tagData.appDataMapList.data.stateTabs;
                        }
                        await this.initMap(this.localPoint, this.tagData.appDataMapList.data);
                    }
                });
                break;
            }
            document.getElementById("subTabs_state" + i).style.background = (type === i) ? "rgba(245,245,247,1)" : "rgba(255,255,255,1)";
            document.getElementById("subTabs_state" + i).style.borderRadius = (type === i) ? "11px 0px 0px 11px" : "0px";
        }
    }
    industryClick(type, len, code, name) {
        const mapLevel = this.map.getZoom();
        for (let i = 0; i < len; i++) {
            if (type === i && mapLevel >= 11) {
                this.industryBean.value = code;
                const label = '全' + name;
                this.industryBean.checkLabel = label;
                const params = this.dataType === 1 ? { content: { level: this.dataLevel, code: this.dataLevelCode, dataType: this.dataType, showName: this.transferRentState === 0 ? "#opportunity_transfer" : "#opportunity_rent", opportunity_plugin_id: this.transferRentState === 0 ? 1 : 2, mapGroupBy: this.dataLevel === 'city' ? 'opportunity_city_id' : 'opportunity_district_id', keyword: "", industryList: code, areaList: this.areaBean.value }, id: this.contextFormId, sessionId: localStorage.getItem('sessionId') } : { content: { level: this.dataLevel, opportunity_expect_district: this.dataLevelCode, dataType: this.dataType, showName: this.transferRentState === 0 ? "#opportunity_transfer" : "#opportunity_rent", opportunity_plugin_id: 3, mapGroupBy: 'opportunity_expect_city', keyword: "", industryList: code, areaList: this.areaBean.value }, id: this.contextFormId, sessionId: localStorage.getItem('sessionId') };
                this.httpService.post('application/submit', params, async (res) => {
                    if (res) {
                        if (typeof res.data.data !== 'string') {
                            this.tagData.appDataMapList.data = res.data.data;
                        } else {
                            this.tagData.appDataMapList.data = await JSON.parse(res.data.data);
                        }
                        if (this.tagData.appDataMapList.data.level === 'city') {
                            this.formatCityData.infoList = this.tagData.appDataMapList.data.infoList;
                            this.formatCityData.statistics = this.tagData.appDataMapList.data.statistics;
                            this.formatCityData.stateTabs = this.tagData.appDataMapList.data.stateTabs;
                        }
                        await this.initMap(this.localPoint, this.tagData.appDataMapList.data);
                    }
                });
                break;
            }
            document.getElementById("subTabs-infoD2-d2" + i).style.background = type === i ? "rgba(245,245,247,1)" : "rgba(255,255,255,1)";
            document.getElementById("subTabs-infoD2-d2" + i).style.borderRadius = type === i ? "11px 0px 0px 11px" : "0px";
        }
    }
    updateAppDataMapList(data: any) { const that = this; that.tagData.appDataMapList.data.infoList = data.infoList; that.tagData.appDataMapList.data.statistics = data.statistics; that.tagData.appDataMapList.data.stateTabs = data.stateTabs; }
    getGroupByStr() { return this.dataType === 1 ? "opportunity_district_id" : "opportunity_expect_district"; }
    dismiss() { this.appGlobalService.goBack(); }
    searchMap(event?) {
        if (event && event.keyCode !== 13) {
            return;
        }
        this.searchBar.getInputElement().then((input) => {
            console.log(input);
            input.blur();
        });
        const that = this;
        if (this.streetDetail === '') {

        } else {
            console.log('搜索:' + this.streetDetail);
            const bs = this.map.getBounds();
            const bsne = bs.getNorthEast();
            const bssw = bs.getSouthWest();
            const params = { content: { level: that.dataLevel, code: that.dataLevelCode, dataType: that.dataType, mapGroupBy: that.dataLevel === 'city' ? 'opportunity_city_id' : 'opportunity_district_id', location: { content: { ll1: { longitude: bsne.lng, latitude: bsne.lat }, ll2: { longitude: bs.Ge, latitude: bs.Yd }, ll3: { longitude: bs.Le, latitude: bs.Wd }, ll4: { longitude: bssw.lng, latitude: bssw.lat } } }, keyword: this.streetDetail, industryList: this.industryBean.value, areaList: this.areaBean.value, }, id: this.contextFormId, sessionId: localStorage.getItem('sessionId') };
            this.httpService.post('application/submit', params, (res) => {
                if (res) {
                    if (typeof res.data.data !== 'string') {
                        this.tagData.appDataMapList.data = res.data.data;
                    } else {
                        this.tagData.appDataMapList.data = JSON.parse(res.data.data);
                    }
                    if (that.dataLevel === 'city') {
                        this.formatCityData.infoList = this.tagData.appDataMapList.data.infoList;
                        this.formatCityData.statistics = this.tagData.appDataMapList.data.statistics;
                        this.formatCityData.stateTabs = this.tagData.appDataMapList.data.stateTabs;
                    } else if (that.dataLevel === 'district') {
                        this.formatDistrictData.infoList = this.tagData.appDataMapList.data.infoList;
                        this.formatDistrictData.statistics = this.tagData.appDataMapList.data.statistics;
                        this.formatDistrictData.stateTabs = this.tagData.appDataMapList.data.stateTabs;
                    } else if (that.dataLevel === 'point') {
                        this.formatPointData.infoList = this.tagData.appDataMapList.data.infoList;
                        this.formatPointData.statistics = this.tagData.appDataMapList.data.statistics;
                        this.formatPointData.stateTabs = this.tagData.appDataMapList.data.stateTabs;
                    }
                    that.initMap(that.localPoint, this.tagData.appDataMapList.data);
                }
            });
        }
    }
    touchClear(event) { } buttonClick() { }
    chosenCity() { const titleBar = JSON.parse(localStorage.getItem('tabTitleBar')); if (titleBar && titleBar['target']) { this.showCityModel(titleBar['target']); } }
    async showCityModel(target) {
        const modal = await this.modalController.create({
            component: ChooseCityComponent,
            componentProps: { value: target, modalTitle: '选择城市', noStorage: true, entryType: 1 }  //    首页是1 默认不传或者0
        });
        modal.onDidDismiss().then((data) => {
            const value = data.data;
            if (value !== undefined && value !== undefined) {
                if (value.name) {
                    document.getElementById('identityMapCity').innerHTML = value.name;
                    this.checkLevelCityData(this.map);
                    this.dataLevel = 'city';
                    this.map.enableScrollWheelZoom();
                    if (this.cityLabel.name !== '') {
                        this.dataLevelCode = this.cityLabel.code;
                        this.currentClickPt.longitude = this.cityLabel.longitude;
                        this.currentClickPt.latitude = this.cityLabel.latitude;
                        this.chartCenterLabel.nativeElement.innerHTML = this.cityLabel.name;
                        this.map.centerAndZoom(new BMap.Point(this.cityLabel.longitude, this.cityLabel.latitude), 11);
                    } else {
                        const pStore = JSON.parse(localStorage.getItem('mapPosition'));
                        const localCityName = pStore.name;
                        this.dataLevelCode = pStore.code;
                        this.currentClickPt.longitude = pStore.center.lng;
                        this.currentClickPt.latitude = pStore.center.lat;
                        this.chartCenterLabel.nativeElement.innerHTML = localCityName;
                        this.map.centerAndZoom(new BMap.Point(pStore.center.lng, pStore.center.lat), 11);
                    }
                }
            }
        });
        return await modal.present();
    }
}